package com.strive.village.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.strive.village.mapper.TbResidentMapper;
import com.strive.village.service.*;
import com.strive.village.utils.DBResidentUploadUtils;
import com.strive.village.utils.DBVillageUploadUtils;
import com.strive.village.utils.RedisUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.ServletRequestUtils;

import javax.servlet.http.HttpServletRequest;

/**
 * @Author: strivePeng
 * @CreateTime: 2024年04月18日
 * @Description:
 **/
public class BaseController {
    /**
     * 注入一些基础的Bean
     */
    @Autowired
    public HttpServletRequest req;

    @Autowired
    public RedisUtils redisUtils;

    @Autowired
    SysUserService sysUserService;

    @Autowired
    SysMenuService sysMenuService;

    @Autowired
    SysRoleService sysRoleService;

    @Autowired
    SysUserRoleService sysUserRoleService;

    @Autowired
    SysRoleMenuService sysRoleMenuService;

    @Autowired
    TbVillageService villageService;
    @Autowired
    TbResidentService residentService;
    @Autowired
    TbResidentMapper residentMapper;

    @Autowired
    DBResidentUploadUtils residentUploadUtils;

    @Autowired
    DBVillageUploadUtils villageUploadUtils;

    /**
     * 初始化查询的分页条件数据
     *
     * @return 当前页数 每页显示数
     */
    public Page getPage() {
        int current = ServletRequestUtils.getIntParameter(req, "current", 1);
        int size = ServletRequestUtils.getIntParameter(req, "size", 10);
        return new Page(current, size);
    }
}
